package master;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

public class AlignBox extends JPanel {
    private static final long serialVersionUID = 1L;

    public AlignBox(JComponent input) {
	this(input, SwingConstants.CENTER, false);
    }
    
    public AlignBox(JComponent input,boolean opaque) {
	this(input,SwingConstants.CENTER,false);
    }

    public AlignBox(JComponent input, int alignment, boolean opaque) {
	this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
	if (alignment == SwingConstants.CENTER
		|| alignment == SwingConstants.RIGHT)
	    this.add(Box.createHorizontalGlue());
	this.add(input);
	if (alignment == SwingConstants.CENTER
		|| alignment == SwingConstants.LEFT)
	    this.add(Box.createHorizontalGlue());
	this.setOpaque(opaque);

    }

}
